<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div>
        <input type="text" v-model="num1" placeholder="请输入数字">
        <input type="text" v-model="num2" placeholder="请输入数字">
        <input type="button"  value="+" @click="f(1)">
        <input type="button"  value="-" @click="f(2)">
        <input type="button"  value="*" @click="f(3)">
        <input type="button"  value="/" @click="f(4)">
        <h3>
            结果：{{num}}
        </h3>
    </div>
    <script src="../day06/vue.min.js"></script>

    <script>
        let v=new Vue({
            el:"body>div",
            data:{
                num:"",num1:" ",num2:" "
            },
            methods:{

                f(num){
                    if (isNaN(v.num1)||isNaN(v.num2)){
                        v.num="输入错误，请输入数字";
                        return;
                    }
                    switch (num){
                        case 1:v.num=v.num1*1+v.num2*1;break;
                        case 2:v.num=v.num1*1-v.num2*1;break;
                        case 3:v.num=v.num1*1*v.num2*1;break;
                        case 4:v.num=v.num1*1/v.num2*1;break;
                    }

                }
            }
        })
    </script>
</body>
</html>